package com.aos.erp.manager.rest.school;

import com.aos.erp.common.bean.ResultEntity;
import com.aos.erp.manager.enums.sys.DepartmentType;
import com.aos.erp.manager.model.sys.Department;
import com.aos.erp.manager.service.sys.DepartmentService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: erp
 * @description: 部门组织controller
 * @author: tanzhiyu
 * @create: 2018-11-01 19:27
 **/
@Api(value = "驾校部门组织api", tags = {"部门组织API"})
@RestController("RESTDSchoolDepartmentController")
@RequestMapping("/api/school/department")
public class DepartmentController {
    @Resource
    private DepartmentService departmentService;

    @PostMapping("/list")
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页码", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "limit", value = " 每页显示条数", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "depCode", value = "部门组织code", required = false, dataType = "String", paramType = "Query"),
            @ApiImplicitParam(name = "depName", value = "部门名称", required = false, dataType = "String", paramType = "Query"),
            @ApiImplicitParam(name = "depType", value = "部门类型", required = true, dataType = "String", paramType = "Query"),
            @ApiImplicitParam(name = "parentCode", value = "部门父级code", required = true, dataType = "String", paramType = "Query")
    })
    public ResultEntity<IPage<Department>> queryPageBean(@RequestParam(name = "page", defaultValue = "1") Integer page,
                                                         @RequestParam(name = "limit", defaultValue = "10") Integer limit,
                                                         @RequestParam(name = "depCode", required = false) String depCode,
                                                         @RequestParam(name = "depName", required = false) String depName,
                                                         @RequestParam(name = "depType", required = false) String depType,
                                                         @RequestParam(name = "parentCode", required = false) String parentCode) throws Exception {

        return ResultEntity.success(departmentService.queryByPage(page, limit, depCode, depName,depType, parentCode));
    }
}
